package com.example.controlexercise;

import androidx.appcompat.app.AppCompatActivity;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class switchTest extends AppCompatActivity {

    private EditText account,pws1,pws2;
    public SharedPreferences sharedPreferences;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_switch_test);
    }
    public void setAddCount(View view){
        account = findViewById(R.id.account);
        pws1 = findViewById(R.id.pws1);
        pws2 =findViewById(R.id.pws2);
        if (pws2.getText()==pws2.getText()){
            sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
            SharedPreferences.Editor editor = sharedPreferences.edit();
            editor.putString("account",account.getText().toString());
            editor.putString("password",pws1.getText().toString());
            editor.apply();
            Toast.makeText(switchTest.this,"注册成功",Toast.LENGTH_SHORT).show();
            Toast.makeText(switchTest.this,sharedPreferences.getString("account",""),Toast.LENGTH_SHORT).show();
        }
    }
}